package xin.marcher.module.construction.remote;

import org.apache.dubbo.config.annotation.DubboReference;
import org.springframework.stereotype.Component;
import xin.marcher.module.common.core.JsonResult;
import xin.marcher.module.common.exception.BaseBizException;
import xin.marcher.module.seller.api.SellerAbilityApi;
import xin.marcher.module.seller.domain.request.SellerInfoRequest;

import java.util.List;

/**
 * 卖家API
 */
@Component
public class SellerRemote {

    @DubboReference(version = "1.0.0")
    private SellerAbilityApi sellerAbilityApi;

    /**
     * 获取卖家下的所有子卖家ID集合
     *
     * @param sellerId
     * @param sellerType
     * @return
     */
    public List<Long> getChildSellerIdList(Long sellerId, Integer sellerType) {
        SellerInfoRequest request = new SellerInfoRequest();
        request.setSellerId(sellerId);
        request.setSellerType(sellerType);
        JsonResult<List<Long>> result = sellerAbilityApi.getChildSellerIdList(request);
        if (!result.getSuccess()) {
            throw new BaseBizException(result.getErrorMessage(), result.getErrorCode());
        }
        return result.getData();
    }

}
